package com.foreknow.service.impl;

import com.foreknow.dao.UserMapper;
import com.foreknow.entity.User;
import com.foreknow.service.UserService;
import com.foreknow.utils.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User Login(String username, String password) {
        return userMapper.queryOne(username, password);
    }

    @Override
    public List<User> queryAllUser(String query) {
        return userMapper.findUser(query);
    }

    @Override
    public boolean removeUserById(Integer id) {
        return userMapper.deleteUserById(id) == 1;
    }

    @Override
    public boolean modifyUser(User user) {
        return userMapper.updateUser(user) == 1;
    }

    @Override
    public boolean addUser(User user) {
        return userMapper.insertUser(user) == 1;
    }

    @Override
    public Integer removeUsers(List<Integer> ids) {
        return userMapper.deleteUsersById(ids);
    }

    @Override
    public User queryUserById(Integer id) {
        return userMapper.findUserById(id);
    }

    @Override
    public List<User> heightQueryUser(User user) {
        return userMapper.heightFindUser(user);
    }
}
